package org.example.lesson02;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

public class les02_Demo_07 {
    public static void main(String[] args) throws IOException {
        //创建一个输出流
        FileOutputStream fileOutputStream = new FileOutputStream("d:/javacode/aaa/abc.txt");
        //根据输出流，创建一个PrintWriter对象，用于写入字符串
        PrintWriter printWriter = new PrintWriter(fileOutputStream);
        //写入内容
        printWriter.println("Hello,World!!!");
        printWriter.println("你好，世界!!!");
        printWriter.println("重生之我在异世界刷怪");
        //强制刷新缓冲区
        printWriter.flush();
        //关闭资源
        printWriter.close();
        fileOutputStream.close();
    }
}
